﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Entities;

/// <summary>
/// Summary description for CustomerData
/// </summary>
public class CustomerData
{
		//
		// TODO: Add constructor logic here
		//
    ShoppingCartDataContext ctx;
    public CustomerData()
    {
        ctx = new ShoppingCartDataContext();
    }
    public bool AddNewCustomer(Customer cus)
    {
        ctx.Customers.InsertOnSubmit(cus);
        ctx.SubmitChanges();
        return true;
    }

    public Customer getCustomer()
    {
        Customer cus = (from c in ctx.Customers
                        orderby c.CustomerID descending
                        select c).First();
        return cus;
    }

    public void AddOrder()
    {

        ctx.SubmitChanges();
    }

    public void AddNewOrder(Order or)
    {
        ctx.Orders.InsertOnSubmit(or);
        ctx.SubmitChanges();
    }

    public void AddNewOrderDetail(OrderDetail orderDetail)
    {
        ctx.OrderDetails.InsertOnSubmit(orderDetail);
        ctx.SubmitChanges();
    }
	
}